//
//  HotMovieTableViewCell.m
//  A段项目
//
//  Created by ～whc on 15-6-19.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "HotMovieTableViewCell.h"

@implementation HotMovieTableViewCell

- (void)dealloc
{
    [self.img release];
    [self.t release];
    [self.r release];
    [self.rd release];
    [self.commonSpecial release];
    [self.NearestCinemaCount release];
    [self.versions1 release];
    [self.versions2 release];
    [self.versions3 release];
    [self.mov release];
    [self.label release];
    [self.imagePlay release];
    
    [super dealloc];
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        if (WIDTH == 320 && HEIGHT == 568) {
            [self creatTable5];
        }
        if (WIDTH == 414 && HEIGHT == 736) {
            [self creatTablePlus];
        }
        if (WIDTH == 375 && HEIGHT == 667){
            [self creatTable6];
        }
        
    }
    return self;

}
-(void)creatTable5
{
    NSLog(@"5");
    self.img = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 90, 150)];
    [self.contentView addSubview:self.img];
    [_img release];
    
    self.imagePlay = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"iconfont-bofang-2.png"]];
    self.imagePlay.frame = CGRectMake(25, 60, 40, 40);
    
    [self.imagePlay release];
    
    
    self.t = [[UILabel alloc]initWithFrame:CGRectMake(self.img.frame.origin.x+self.img.frame.size.width+15, self.img.frame.origin.y - 5, 140, 30)];
//    [self.t setBackgroundColor:[UIColor redColor]];
    self.t.numberOfLines = 0;
    self.t.font = [UIFont boldSystemFontOfSize:16];
    [self.contentView addSubview:self.t];
    [_t release];
    
    
    
    self.commonSpecial = [[UILabel alloc]initWithFrame:CGRectMake(self.t.frame.origin.x, self.t.frame.origin.y+self.t.frame.size.height, 200, 30)];
    self.commonSpecial.font = [UIFont boldSystemFontOfSize:15];
    self.commonSpecial.textColor = [UIColor orangeColor];
//    [self .commonSpecial setBackgroundColor:[UIColor redColor]];
    [self.contentView addSubview:self.commonSpecial];
    [_commonSpecial release];
    
    self.rd = [[UILabel alloc]initWithFrame:CGRectMake(self.commonSpecial.frame.origin.x, self.commonSpecial.frame.origin.y+30, 150, 30)];
    self.rd.textColor = [UIColor lightGrayColor];
    self.rd.font = [UIFont boldSystemFontOfSize:15];
    [self.contentView addSubview:self.rd];
    [_rd release];
    
    self.label = [[UILabel alloc]initWithFrame:CGRectMake(self.rd.frame.origin.x + self.rd.frame.size.width+10, self.rd.frame.origin.y, 100, 30)];
    self.label.font = [UIFont boldSystemFontOfSize:15];
    [self.contentView addSubview:self.label];
    [_label release];
    
    
    self.NearestCinemaCount = [[UILabel alloc]initWithFrame:CGRectMake(self.rd.frame.origin.x, self.rd.frame.origin.y+30, 200, 30)];
    //    self.NearestCinemaCount.textColor = [UIColor lightGrayColor];
    self.NearestCinemaCount.font = [UIFont boldSystemFontOfSize:15];
    [self.contentView addSubview:self.NearestCinemaCount];
    [_NearestCinemaCount release];
    
    
    self.r = [[UILabel alloc]initWithFrame:CGRectMake(255, self.img.frame.origin.y - 5, 70, 30)];
    
    self.r.font = [UIFont systemFontOfSize:15];
    self.r.textColor = [UIColor greenColor];
    [self.contentView addSubview:self.r];
    [_r release];
    
    
    
    
    
}


-(void)creatTable6
{
    self.img = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 110, 170)];
    [self.contentView addSubview:self.img];
    [_img release];
    
    self.imagePlay = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"iconfont-bofang-2.png"]];
    self.imagePlay.frame = CGRectMake(35, 60, 40, 40);
    
    [self.imagePlay release];
    
    
    self.t = [[UILabel alloc]initWithFrame:CGRectMake(self.img.frame.origin.x+self.img.frame.size.width+15, self.img.frame.origin.y+5, 170, 30)];
//    [self.t setBackgroundColor:[UIColor redColor]];
    self.t.numberOfLines = 0;
    self.t.font = [UIFont boldSystemFontOfSize:18];
    [self.contentView addSubview:self.t];
    [_t release];
    
    
    
    self.commonSpecial = [[UILabel alloc]initWithFrame:CGRectMake(self.t.frame.origin.x, self.t.frame.origin.y+self.t.frame.size.height, 220, 30)];
    self.commonSpecial.font = [UIFont boldSystemFontOfSize:16];
    self.commonSpecial.textColor = [UIColor orangeColor];
    [self.contentView addSubview:self.commonSpecial];
    [_commonSpecial release];
    
    self.rd = [[UILabel alloc]initWithFrame:CGRectMake(self.commonSpecial.frame.origin.x, self.commonSpecial.frame.origin.y+30, 150, 30)];
    self.rd.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.rd];
    [_rd release];
    
    self.label = [[UILabel alloc]initWithFrame:CGRectMake(self.rd.frame.origin.x + self.rd.frame.size.width+10, self.rd.frame.origin.y, 100, 30)];
    [self.contentView addSubview:self.label];
    [_label release];
    

    self.NearestCinemaCount = [[UILabel alloc]initWithFrame:CGRectMake(self.rd.frame.origin.x, self.rd.frame.origin.y+30, 200, 30)];
//    self.NearestCinemaCount.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.NearestCinemaCount];
    [_NearestCinemaCount release];

    
    self.r = [[UILabel alloc]initWithFrame:CGRectMake(300, self.img.frame.origin.y+5, 70, 30)];
    
    self.r.font = [UIFont systemFontOfSize:18];
    self.r.textColor = [UIColor greenColor];
    [self.contentView addSubview:self.r];
    [_r release];
    

    
    
    
}

-(void)creatTablePlus
{
    NSLog(@"PLUS");
    
    self.img = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 110, 170)];
    [self.contentView addSubview:self.img];
    [_img release];
    
    self.imagePlay = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"iconfont-bofang-2.png"]];
    self.imagePlay.frame = CGRectMake(35, 60, 40, 40);
    [self.imagePlay release];
    
    
    self.t = [[UILabel alloc]initWithFrame:CGRectMake(self.img.frame.origin.x+self.img.frame.size.width+15, self.img.frame.origin.y+5, 210, 30)];
    //    [self.t setBackgroundColor:[UIColor redColor]];
    self.t.numberOfLines = 0;
    self.t.font = [UIFont boldSystemFontOfSize:18];
    [self.contentView addSubview:self.t];
    [_t release];
    
    
    
    self.commonSpecial = [[UILabel alloc]initWithFrame:CGRectMake(self.t.frame.origin.x, self.t.frame.origin.y+self.t.frame.size.height, 270, 30)];
    self.commonSpecial.font = [UIFont boldSystemFontOfSize:16];
    self.commonSpecial.textColor = [UIColor orangeColor];
    [self.contentView addSubview:self.commonSpecial];
    [_commonSpecial release];
    
    self.rd = [[UILabel alloc]initWithFrame:CGRectMake(self.commonSpecial.frame.origin.x, self.commonSpecial.frame.origin.y+30, 150, 30)];
    self.rd.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.rd];
    [_rd release];
    
    self.label = [[UILabel alloc]initWithFrame:CGRectMake(self.rd.frame.origin.x + self.rd.frame.size.width+10, self.rd.frame.origin.y, 100, 30)];
    [self.contentView addSubview:self.label];
    [_label release];
    
    
    self.NearestCinemaCount = [[UILabel alloc]initWithFrame:CGRectMake(self.rd.frame.origin.x, self.rd.frame.origin.y+30, 200, 30)];
    //    self.NearestCinemaCount.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.NearestCinemaCount];
    [_NearestCinemaCount release];
    
    
    self.r = [[UILabel alloc]initWithFrame:CGRectMake(340, self.img.frame.origin.y+5, 70, 30)];
    
    self.r.font = [UIFont systemFontOfSize:18];
    self.r.textColor = [UIColor greenColor];
    [self.contentView addSubview:self.r];
    [_r release];
    
    
    
    
    
}


-(void)setMov:(Movie *)mov
{
    if (_mov != mov) {
        [_mov release];
        _mov = [mov retain];
    }

    self.t.text = mov.t;
   
    self.commonSpecial.text = mov.commonSpecial;
    NSString *str = mov.rd;
    NSRange range1 = NSMakeRange(4, 2);
    NSString *str1 = [str substringWithRange:range1];
    NSRange range2 = NSMakeRange(6, 2);
    NSString *str2 = [str substringWithRange:range2];
    self.rd.text = [NSString stringWithFormat:@"%@月%@日上映",str1,str2];
//    NSString *str3 = mov.NearestCinemaCount;
//    NSString *str4 = mov.NearestShowtimeCount;
//    self.NearestCinemaCount.text = [NSString stringWithFormat:@"今日%@家影院上映%@场",str3,str4];
    self.NearestCinemaCount.text = @"点击进入播放列表";
    NSURL *url = [NSURL URLWithString:mov.img];
    [self.img sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"111111.png"]];
   [self.img addSubview:self.imagePlay];
    if (mov.r >= 0) {
        self.r.text = [NSString stringWithFormat:@"评分:%.1f",mov.r];

    }
//    if ([mov.isNew isEqualToString:@"1"]) {
//        self.label.text = @"即将上映";
//    }
    
    if (WIDTH == 320 && HEIGHT == 568) {
        if ([mov.is3D isEqualToString:@"1"]) {
            
            self.versions1 = [[UILabel alloc]initWithFrame:CGRectMake(self.NearestCinemaCount.frame.origin.x, self.NearestCinemaCount.frame.origin.y+self.NearestCinemaCount.frame.size.height+ 5, 25, 25)];
            self.versions1.text = @"3D";
            self.versions1.textColor = [UIColor lightGrayColor];
            self.versions1.layer.borderWidth = 1;
            self.versions1.font = [UIFont systemFontOfSize:15];
            self.versions1.textAlignment = NSTextAlignmentCenter;
            [self.contentView addSubview:self.versions1];
            [_versions1 release];
            
            
            if ([mov.isIMAX3D isEqualToString:@"1"]) {
                self.versions2 = [[UILabel alloc]initWithFrame:CGRectMake(self.versions1.frame.origin.x+self.versions1.frame.size.width+5, self.versions1.frame.origin.y, 70, 25)];
                self.versions2.textColor = [UIColor lightGrayColor];
                self.versions2.text = @"IMAX3D";
                self.versions2.textAlignment = NSTextAlignmentCenter;
                self.versions2.layer.borderWidth = 1;
                self.versions2.font = [UIFont systemFontOfSize:15];
                [self.contentView addSubview:self.versions2];
                [_versions2 release];
                
                if ([mov.isDMAX isEqualToString:@"1"]) {
                    self.versions3 = [[UILabel alloc]initWithFrame:CGRectMake(self.versions2.frame.origin.x+self.versions2.frame.size.width+5, self.versions2.frame.origin.y, 70, 25)];
                    self.versions3.textColor = [UIColor lightGrayColor];
                    self.versions3.font = [UIFont systemFontOfSize:15];
                    self.versions3.textAlignment = NSTextAlignmentCenter;
                    self.versions3.text = @"中国巨幕";
                    self.versions3.layer.borderWidth = 1;
                    [self.contentView addSubview:self.versions3];
                    [_versions3 release];
                }
            }
        }
        }else{
            if ([mov.is3D isEqualToString:@"1"]) {
            
            self.versions1 = [[UILabel alloc]initWithFrame:CGRectMake(self.NearestCinemaCount.frame.origin.x, self.NearestCinemaCount.frame.origin.y+self.NearestCinemaCount.frame.size.height+10, 30, 30)];
            self.versions1.text = @"3D";
            self.versions1.textColor = [UIColor lightGrayColor];
            self.versions1.layer.borderWidth = 1;
            self.versions1.textAlignment = NSTextAlignmentCenter;
            [self.contentView addSubview:self.versions1];
            [_versions1 release];
            
            
            if ([mov.isIMAX3D isEqualToString:@"1"]) {
                self.versions2 = [[UILabel alloc]initWithFrame:CGRectMake(self.versions1.frame.origin.x+self.versions1.frame.size.width+5, self.versions1.frame.origin.y, 80, 30)];
                self.versions2.textColor = [UIColor lightGrayColor];
                self.versions2.text = @"IMAX3D";
                self.versions2.textAlignment = NSTextAlignmentCenter;
                self.versions2.layer.borderWidth = 1;
                [self.contentView addSubview:self.versions2];
                [_versions2 release];
                
                if ([mov.isDMAX isEqualToString:@"1"]) {
                    self.versions3 = [[UILabel alloc]initWithFrame:CGRectMake(self.versions2.frame.origin.x+self.versions2.frame.size.width+5, self.versions2.frame.origin.y, 80, 30)];
                    self.versions3.textColor = [UIColor lightGrayColor];
                    self.versions3.textAlignment = NSTextAlignmentCenter;
                    self.versions3.text = @"中国巨幕";
                    self.versions3.layer.borderWidth = 1;
                    [self.contentView addSubview:self.versions3];
                    [_versions3 release];
                }
            }
        }

            
        

    }
    
}














- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
